//
//  PricvacyViewController.swift
//  CJXSwiftStoryboard
//
//  Created by CJX on 2016/10/22.
//  Copyright © 2016年 caijianxi. All rights reserved.
//

import UIKit

class PricvacyViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
    
    
    var myTableView = UITableView(frame: CGRect(x: 0, y: 64, width: SCREEN_WIDTH, height: SCREEN_HEIGHT-64), style: .plain)

    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.automaticallyAdjustsScrollViewInsets = false
        self.creatNavVIew()
        self.view.backgroundColor = UIColor.white
        self.navigationController?.navigationBar.barTintColor = UIColor(red: 94/255.0, green: 200/255.0, blue: 252/255.0, alpha: 1)
        self.title = "SHIPPING POLICY"
        
        self.creatTableView()
    }
    
    
}


extension PricvacyViewController{
    
    fileprivate func creatNavVIew(){
        let leftBtn = UIButton(type: .custom)
        leftBtn.setImage(UIImage(named: "nav_back"), for: UIControlState())
        leftBtn.frame = CGRect(x: 0, y: 0, width: 30, height: 30)
        leftBtn.addTarget(self, action: #selector(leftBtnClick), for: .touchUpInside)
        let item = UIBarButtonItem(customView: leftBtn)
        self.navigationItem.leftBarButtonItem = item
    }
    
    func leftBtnClick(){
        self.dismiss(animated: true) {
            
        }
    }
}

extension PricvacyViewController{
    
    fileprivate func creatTableView(){
        
        myTableView.delegate = self
        myTableView.dataSource = self
        self.view.addSubview(myTableView)
        
        
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCell(withIdentifier: "cell")
        if cell == nil {
            cell = UITableViewCell(style: .default, reuseIdentifier: "cell")
        }

        
        let img = UIImageView()
        img.image = UIImage(named: "biaoge")
        cell?.addSubview(img)
        
        if SCREEN_WIDTH == 320 {
            img.frame = CGRect(x: 10, y: 0, width: SCREEN_WIDTH-20, height: 2479)
        }else if SCREEN_WIDTH > 320 && SCREEN_WIDTH < 430{
            img.frame = CGRect(x: 10, y: 0, width: SCREEN_WIDTH-20, height: 2933)
        }else{
            img.frame = CGRect(x: 10, y: 0, width: SCREEN_WIDTH-20, height: 3256)
        }
        
        
        return cell!
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        if SCREEN_WIDTH == 320 {
            return 2579
        }else if SCREEN_WIDTH > 320 && SCREEN_WIDTH < 430{
            return SCREEN_HEIGHT + 3033
        }else{
            return SCREEN_HEIGHT + 3356
        }
    }
}
